
package pt.inescid.components.jobmanager;

import java.util.Vector;

/**
 * @author Sergio Esteves (sesteves at gsd.inesc-id.pt)
 *
 */
public class JobHolder {

	private int jobHandler;
	
	private String appID;
	
	private int nTasks;
	
	private int tasksCompleted = 0;
	
	private String configLocation;
	
	private String outputLocation;	
	
	private Vector<byte[]> taskResults;
	
	public JobHolder(int jobHandler, String appID, int nTasks, String configLocation, 
			String outputLocation) {
		this.jobHandler = jobHandler;
		this.appID = appID;
		this.nTasks = nTasks;
		this.taskResults = new Vector<byte[]>();
		this.taskResults.setSize(nTasks);
		this.configLocation = configLocation;
		this.outputLocation = outputLocation;
	}
	
	public int getJobHandler() {
		return jobHandler;
	}
	public String getAppID() {
		return appID;
	}
	public int getNTasks() {
		return nTasks;
	}
	public String getConfigLocation() {
		return configLocation;
	}
	public String getOutputLocation() {
		return outputLocation;
	}
	public Vector<byte[]> getTaskResults() {
		return taskResults;
	}
	
	public boolean contains(int nTask) {
		return taskResults.get(nTask) != null;
	}
	
	public void addTaskResult(int nTask, byte[] data) {
		taskResults.set(nTask, data);
		tasksCompleted++;
	}
	
	public boolean isCompleted() {
		if(tasksCompleted == nTasks)
			return true;
		return false;
	}
}
